package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.UserDto;
import com.zzyl.service.UserService;
import com.zzyl.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 新增用户
     * @param userDto
     * @return
     */
    @PutMapping
    public ResponseResult addUser(@RequestBody UserDto userDto) {
        userService.addUser(userDto);
        return ResponseResult.success(true);
    }
    @PostMapping("/page/{pageNum}/{pageSize}")
    public ResponseResult<PageResponse<UserVo>>getUserPage(@RequestBody UserDto userDto, @PathVariable Integer pageNum, @PathVariable Integer pageSize){
        PageResponse<UserVo> pageResponse=userService.getUserPage(userDto,pageNum,pageSize);
        return ResponseResult.success(pageResponse);
    }
}
